
//
// 101125 - AH - Created.
// 110519 - AH - Version 0.5 and added team tab.
// 110602a- AH - Version 1.1.
// 110602b- AH - (Hector) Version 1.2 and added Eileng in team tab.
// 110603 - AH - (Garage) Changed Laetitia's about picture from 
//               laetitia_about.jpg
// 110608 - AH - Version 1.3.
// 110617 - AH - Version 1.4.
// 110618 - AH - Fixed that picture of me displayed where logo should and shows
//               now latest logo.
// 110619 - AH - Version 1.5.
// 110718 - AH - Version 1.6.
// 110719 - AH - Version 1.7.
// 110906 - AH - (Huset) Version 1.8.
// 120205 - AH - (Opera) Version 1.91 (forgot mark 1.9 here ;.()
// 120227 - AH - Version 1.92.
// 120301 - AH - Version 2.00 Post master version.
//

package org.soekrat.gui.swing;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.net.URL;

import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import org.soekrat.gui.swing.synesthesia.ImageUtil;

/**
 * <p>
 *   Soekrat's about dialog.
 * </p>
 * @author Arne Halvorsen (AH).
 * @author Laetitia Le Chatton (LLC) 
 */
@SuppressWarnings("serial")
public final class AboutDialog extends JDialog 
{
  private final String m_version="2.0";
  
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public AboutDialog(){ buildGui(); }
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param p Dialog's parent.
   */
  public AboutDialog(Frame p){ super(p); buildGui(); }
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param p Dialog's parent.
   */
  public AboutDialog(Dialog p){ super(p); buildGui(); }

  // Invoked from constructors.
  private void buildGui()
  {
    setTitle("About");
    setModal(true);
    
    Container c=getContentPane();
    c.setLayout(new BorderLayout());
    
    JTabbedPane tabs=new JTabbedPane();
    
    //
    JPanel soekrat=new JPanel(new BorderLayout());
    
    Icon icon=null;
   
    //
    Box team=new Box(BoxLayout.X_AXIS);
    
    Box jan=new Box(BoxLayout.Y_AXIS);
    URL url=ClassLoader.getSystemResource(
      "org/soekrat/gui/swing/jan_about.jpg");
    BufferedImage bi=ImageUtil.scale(url, 250, 250, this);
    if (url!=null)
    {
      icon=new ImageIcon(bi);
      jan.add(new JLabel(icon));
    }
    
    jan.add(new JLabel("Jan Eileng"));
    jan.add(new JLabel("<html><i>Quality Control Chief, AI Specialist</i></html>"));
    jan.add(new JLabel("<html><i>Key Hunter</i></html>"));
    team.add(jan);
   
    Box laetitia=new Box(BoxLayout.Y_AXIS);
    url=ClassLoader.getSystemResource(
      "org/soekrat/gui/swing/laetitia_psycho_about.jpg");
    bi=ImageUtil.scale(url, 250, 250, this);
    if (url!=null) 
    {
      icon=new ImageIcon(bi);
      laetitia.add(new JLabel(icon));
    }
    
    laetitia.add(new JLabel("Laetitia Le Chatton"));
    laetitia.add(new JLabel("<html><i>Philosopher, Software Architect</i></html>"));
    laetitia.add(new JLabel("<html><i>and Painter</i></html>"));
    team.add(laetitia);
    
    Box arne=new Box(BoxLayout.Y_AXIS);
    url=ClassLoader.getSystemResource(
      "org/soekrat/gui/swing/arne_about.jpg");
    bi=ImageUtil.scale(url, 250, 250, this);
    if (url!=null) 
    {
      icon=new ImageIcon(bi);
      arne.add(new JLabel(icon));
    }
    
    arne.add(new JLabel("Arne Halvorsen"));
    arne.add(new JLabel("<html><i>Hacker, Socratic Medium</i></html>"));
    arne.add(new JLabel("<html><i>and Photographer</i></html>"));
    team.add(arne);
    
    tabs.addTab("Team", team);
    
    Box version=new Box(BoxLayout.Y_AXIS);
    
    url=ClassLoader.getSystemResource("org/soekrat/gui/swing/srat.png");
    if (url!=null) icon=new ImageIcon(url);
    if (icon!=null) version.add(new JLabel(icon), JLabel.CENTER);
    
    version.add(Box.createVerticalStrut(10));
    
    version.add(new JLabel("  Version "+m_version+" ", JLabel.CENTER));
    
    version.add(Box.createVerticalStrut(10));
    
    soekrat.add(version, BorderLayout.CENTER);
    tabs.addTab("Soekrat", version);
    //
    
    c.add(tabs, BorderLayout.CENTER);
    
    JPanel buttons=new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttons.add
    (
      new JButton
      (
        new AbstractAction("Close")
        {
          public void actionPerformed(ActionEvent e){ dispose(); }
        }
      )
    );
    c.add(buttons, BorderLayout.SOUTH);
    
    Toolkit tk=Toolkit.getDefaultToolkit();
    Dimension screenSize=tk.getScreenSize();
    int screenHeight=screenSize.height;
    int screenWidth=screenSize.width;
    setSize(screenWidth/2, screenHeight/2);
    setLocation(screenWidth/4, screenHeight/4);
    
    pack();
  }
  
}
